
package uranium.gui.stampa;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.InputStream;

import javax.swing.JFrame;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

/**
 * 
 */

/**
 * @author hunterbit
 */
public class MyJasperViewer extends JasperViewer implements WindowListener
{
	private JFrame				padre				= null;

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	/**
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @throws JRException
	 */
	public MyJasperViewer(InputStream arg0, boolean arg1, boolean arg2) throws JRException
	{
		super(arg0, arg1, arg2);
		addWindowListener(this);
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @throws JRException
	 */
	public MyJasperViewer(InputStream arg0, boolean arg1) throws JRException
	{
		super(arg0, arg1);
		addWindowListener(this);
	}

	/**
	 * @param arg0
	 * @param arg1
	 */
	public MyJasperViewer(JasperPrint arg0, boolean arg1)
	{
		super(arg0, arg1);
		addWindowListener(this);
	}

	/**
	 * @param arg0
	 */
	public MyJasperViewer(JasperPrint arg0)
	{
		super(arg0);
		addWindowListener(this);
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @param arg2
	 * @throws JRException
	 */
	public MyJasperViewer(String arg0, boolean arg1, boolean arg2) throws JRException
	{
		super(arg0, arg1, arg2);
		addWindowListener(this);
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @throws JRException
	 */
	public MyJasperViewer(String arg0, boolean arg1) throws JRException
	{
		super(arg0, arg1);
		addWindowListener(this);
	}

	public void setPadre(JFrame padre)
	{
		this.padre = padre;
	}

	public JFrame getPadre()
	{
		return this.padre;
	}

	public void bloccaPadre()
	{
		this.padre.setEnabled(false);
	}

	public void sbloccaPadre()
	{
		this.padre.setEnabled(true);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
	 */
	public void windowOpened(WindowEvent arg0)
	{
		bloccaPadre();

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
	 */
	public void windowClosing(WindowEvent arg0)
	{
		this.padre.toFront();
		sbloccaPadre();

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
	 */
	public void windowClosed(WindowEvent arg0)
	{
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
	 */
	public void windowIconified(WindowEvent arg0)
	{
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
	 */
	public void windowDeiconified(WindowEvent arg0)
	{
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
	 */
	public void windowActivated(WindowEvent arg0)
	{
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
	 */
	public void windowDeactivated(WindowEvent arg0)
	{
		// TODO Auto-generated method stub

	}

}
